package com.wn.network.error

import java.io.IOException

/**
 * @Author: wn
 * @Date: 2024/7/2 17:13
 * @Description: 结果异常类  -- 1 请求异常 , 2 网络异常
 * Exception extends Throwable
 */
/**
 * 服务器非 200 状态，对应的异常  -- 直接调接口 失败
 */
class ApiException : Exception {
  val errCode: Int
  val errMsg: String

  constructor(error: ERROR, t: Throwable? = null) : super(t) {
    errCode = error.code
    errMsg = error.errMsg
  }

  constructor(code: Int, msg: String, t: Throwable? = null) : super(t) {
    errCode = code
    errMsg = msg
  }
}

/**
 * 网络异常
 */
class NoNetWorkException(error: ERROR, t: Throwable? = null) : IOException(t) {
  val errCode: Int = error.code
  val errMsg: String = error.errMsg
}